package string;

/**
 * String replaceAll(String regex,String s):替换
 * 将当前字符串中满足正则表达式(regex)的部分替换为指定的字符串（s）
 */
public class ReplaceAllDemo {
    public static void main(String[] args) {
        String line = "abc12nb3456tv7890";
        //将数字部分替换成#NUMBER#
        line = line.replaceAll("[0-9]+","#NUMBER#");
        System.out.println(line);
        //和谐脏话
        String words = "xxx,wcnmd,rnm,sb,脑瘫666";
        words = words.replaceAll("(cnm)|(rnm)|(sb)|(脑瘫)","*");
        System.out.println(words);
    }
}
